<?php
class Form_Category extends QForm
{
	function __construct($action)
	{
		// 调用父类的构造函数
		parent::__construct('form_category', $action);

		// 从配置文件载入表单
		$filename = rtrim(dirname(__FILE__), '/\\') . DS . 'category_form.yaml';
		$this->loadFromConfig(Helper_YAML::loadCached($filename));
		$this->addValidations(Categorys::meta());
		$this['model']->addValidations(array($this,'validate_model'),'模型选择错误!');
	}
	
	function validate_model($param) {
		return (bool) Models::find('id = ?',$this['model']->value)->getCount();
	}
}